<!-- 预警 -->
<template>
    <div class="agency">
        <el-table border ref="singleTable" :data="tableData" style="width: 100%" height="310">
            <el-table-column type="index" label="序号" width="50">
            </el-table-column>
            <el-table-column prop="messageInfo" label="预警信息">
            </el-table-column>
            <el-table-column prop="warnTime" label="通知时间" width="260">
            </el-table-column>
        </el-table>
        <div class="paginationModule">
            <Pagination @size-Change="handleSizeChange" :size="size" @current-change="handleCurrentChange" :page="page"
                :total="total">
            </Pagination>
        </div>
    </div>
</template>
<script>
import earlyWarningCenter from '@/api/earlyWarningCenter';
import Pagination from '@/components/Pagination';
export default {
    components: { Pagination },
    props: {
        type: {
            type: String,
            default: () => {
                return ''
            }
        }
    },
    data() {
        return {
            tableData: [],
            page: 1,
            size: 6,
            total: 6
        }
    },
    watch: {},
    computed: {
        person() {
            return this.$store.state.initData.person || [];
        }
    },
    mounted() {
        this.queryPageByCondition();
    },
    methods: {
        queryPageByCondition() {
            let logInfo = sessionStorage.logInfo ? JSON.parse(sessionStorage.logInfo) : {};
            this.userType = logInfo.userType || '';
            let params = {
                page: this.page,
                size: this.size,
                entity: {
                    type: this.type
                }
            }
            earlyWarningCenter.warningRecordList(params).then(res => {
                if (res.code == 1) {
                    this.tableData = res.data.content || [];
                    this.total = res.data.totalElements;
                } else {
                    this.$message.warning(res.msg || '分页查询失败')
                }
            }).catch(err => {
                console.log(err)
            })
        },
        handleCurrentChange(page) {
            this.page = page;
            this.queryPageByCondition();
        },
        handleSizeChange(size) {
            this.size = size;
            this.queryPageByCondition();
        }
    }
};
</script>
<style lang="scss" scoped>
.paginationModule {
    text-align: right;
    margin-top: 5px
}
</style>